package cn.ac.iscas.domain.response.middleplatform;

import java.io.Serializable;
import java.util.Objects;

/**
 * 列的元信息
 *
 * clickhouse 测试建表语句：
 * CREATE TABLE test22
 * (
 * 	c1 Int8,
 * 	c2 Int16,
 * 	c3 Int32,
 * 	c4 Int64,
 * 	c5 UInt8,
 * 	c6 UInt16,
 * 	c7 UInt32,
 * 	c8 UInt64,
 * 	c9 Float64,
 * 	c10 Float32,
 * 	c11 Decimal(10, 0),
 * 	c12 Decimal(10, 2),
 * 	c13 String,
 * 	c14 FixedString(10),
 * 	c15 Nullable(UUID),
 * 	c16 Date,
 * 	c17 DateTime,
 * 	c18 DateTime64,
 * 	c19 DateTime64(4),
 * 	c20 Array(Int8),
 * 	c21 Array(FixedString(5)),
 * 	c22 Tuple(String),
 * 	c23 Enum8('no_password' = 0, 'plaintext_password' = 1, 'sha256_password' = 2, 'double_sha1_password' = 3, 'ldap' = 4, 'kerberos' = 5, 'ssl_certificate' = 6),
 * 	c24 Int32 NULL,
 * 	ip_v4 IPv4,
 * 	ip_v6 IPv6,
 * 	c25 Map(Int8, String)
 *
 * ) ENGINE = MergeTree
 * ORDER BY (c8, c9)
 * sample by c8
 *
 *
 * @author zhuquanwen
 * @version 1.0
 * @date 2022/3/2 17:40
 * @since jdk11
 */
//@Data
//@Accessors(chain = true)
public class MetaColumn implements Serializable {

    /**
     * 库名
     */
    protected String tableSchema;

    /**
     * 表名
     */
    protected String tableName;

    /**
     * 列名
     */
    protected String name;

    /**
     * 默认值
     */
    protected Object defaultVal;

    /**
     * 是否可以为空
     */
    protected boolean nullable = true;

    /**
     * 数据类型
     */
    protected DbColumnType dataType;

    /**
     * 列的顺序
     */
    protected Integer ordinalPosition;

    /**
     * 描述(注释)
     */
    protected String comment;

    /**
     * 长度
     * todo 当前这个长度也是字符串的最大长度，也是浮点型的precision，也是时间类型的precision，所以名字起的有歧义，暂时先这样用
     */
    protected Long charMaxLen;

    /**
     * 是否是主键
     */
    protected boolean primary = false;

    public String getTableSchema() {
        return tableSchema;
    }

    public void setTableSchema(String tableSchema) {
        this.tableSchema = tableSchema;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Object getDefaultVal() {
        return defaultVal;
    }

    public void setDefaultVal(Object defaultVal) {
        this.defaultVal = defaultVal;
    }

    public boolean isNullable() {
        return nullable;
    }

    public void setNullable(boolean nullable) {
        this.nullable = nullable;
    }

    public DbColumnType getDataType() {
        return dataType;
    }

    public void setDataType(DbColumnType dataType) {
        this.dataType = dataType;
    }

    public Integer getOrdinalPosition() {
        return ordinalPosition;
    }

    public void setOrdinalPosition(Integer ordinalPosition) {
        this.ordinalPosition = ordinalPosition;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Long getCharMaxLen() {
        return charMaxLen;
    }

    public void setCharMaxLen(Long charMaxLen) {
        this.charMaxLen = charMaxLen;
    }

    public boolean isPrimary() {
        return primary;
    }

    public void setPrimary(boolean primary) {
        this.primary = primary;
    }
}
